<template>
  <view>
    <web-view :src="url" @message="getMessage"></web-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      url: '',
      title: '万户健康'
    };
  },
  onLoad(options) {
    if (options) {
      if (options.url) {
        this.url = decodeURIComponent(options.url);
      }
      if (options.title) {
        this.title = decodeURIComponent(options.title) || '万户健康';
      }
    }
    console.log('this.url:', this.url);
    uni.setNavigationBarTitle({
      title: this.title
    });
    if (!this.url) {
      uni.showModal({
        title: '提示',
        content: '链接错误，无法打开',
        success: function () {
          uni.navigateBack();
        }
      });
    }
  },
  methods: {
    getMessage(event) {
      uni.showModal({
        content: JSON.stringify(event.detail),
        showCancel: false
      });
    }
  }
};
</script>

<style></style>
